<?php
	include_once("../../MasterPages/headerPHPScript.php");
	$CourseID = ISSET($_GET["CourseID"]) ? $_GET["CourseID"] : "";
	$CourseAnnouncementID = ISSET($_GET["CourseAnnouncementID"]) ? $_GET["CourseAnnouncementID"] : "";
	$Flag = ISSET($_GET["Flag"]) ? $_GET["Flag"] : "";
	$CourseAnnouncementService = new CourseAnnouncementService();
	if(strtolower($Flag)==strtolower("delete"))
	{
		$CourseAnnouncementService->DeleteCourseAnnouncement($CourseAnnouncementID);
	}else{
		$CourseAnnouncementEntity = new CourseAnnouncementEntity();
		if($CourseAnnouncementID!="")
		{
			$CourseAnnouncementEntity->CourseAnnouncementID = $CourseAnnouncementID;
		}
		$CourseAnnouncementEntity->CourseID = $CourseID;		
		$CourseAnnouncementEntity->CourseAnnouncementType = GetValueFromPost("rdoCourseAnnouncementType");		
		$CourseAnnouncementEntity->StartDate = ConvertStringToDate(GetValueFromPost("txtStartDate"));
		$CourseAnnouncementEntity->EndDate = ConvertStringToDate(GetValueFromPost("txtEndDate"));
		$CourseAnnouncementEntity->StartTime = ConvertTimeToString(GetValueFromPost("txtStartTime"));
		$CourseAnnouncementEntity->EndTime = ConvertTimeToString(GetValueFromPost("txtEndTime"));
		$CourseAnnouncementEntity->Topic = GetValueFromPost("txtTopic");
		$CourseAnnouncementEntity->Description = GetValueFromPost("txtDescription");
		if($CourseAnnouncementID!="")
			$CourseAnnouncementService->UpdateCourseAnnouncement($CourseAnnouncementEntity);
		else
			$CourseAnnouncementService->InsertCourseAnnouncement($CourseAnnouncementEntity);
	}
	
	header("location:../index.php?page=teacher-announcement.php&CourseID=$CourseID");
?>